/*
 * @lc app=leetcode id=49 lang=cpp
 *
 * [49] Group Anagrams
 */
class Solution {
public:
    vector<vector<string>> groupAnagrams(vector<string>& strs) {
        vector<vector<string>> ret;
        int len = strs.size();
        if (len < 1) {
            return ret;
        }

        int i = 0;
        unordered_map<string, vector<string>> map;
        for (auto s : strs) {
            string ss = s;
            sort(ss.begin(), ss.end());
            map[ss].push_back(s);
        }
        for (auto kv : map) {
            ret.push_back(kv.second);
        }
        return ret;
    }
};

